#include <stdio.h>


typedef int Node_type;


/* Seria de constantes que servirao para definir tipos de nos (na arvore). */
#define program_node   299
#define idf_node       300
#define int_node       301
#define real_node     302
#define str_node       303
#define empty_node     304
#define proc_node      305
#define param_node     306
#define decl_node      307
#define decl_list_node 308
#define op_node        309
#define nop_node       310
#define return_node    311
#define if_node        312
#define while_node     313
#define print_node     314
#define cond_node      315
#define affect_node    316
#define or_node        317
#define and_node       318
#define eq_node        319
#define neq_node       320
#define inf_node       321
#define sup_node       322
#define inf_eq_node    323
#define sup_eq_node    324
#define plus_node      325
#define minus_node     326
#define mult_node      327
#define div_node       328
#define mod_node       329
#define umenos_node    330
#define not_node       331
#define char_node      332
#define semicolon_node 333
#define comma_node     334
#define true_node      335
#define false_node     336
#define acoes_node     337
#define attrib_node    338
#define abre_colc_node 339
#define fecha_colc_node 340
#define lvalue_node    341
#define listaexpr_node 342
#define doispontos_node 343
#define double_node     344
#define tipolista_node  345
#define intlit_node     346
#define listadupla_node 347
#define comando_node 348
#define expr_node   349
#define abre_parent_node 350
#define fecha_parent_node 351
#define flit_node       352
#define chama_proc_node 353
#define then_node   354
#define enunciado_node 355
#define abre_chave_node 356
#define fecha_chave_node 357
#define end_node 358
#define else_node 359
#define fimcontrole_node 360
#define expbool_node 361

#define MAX_TIPO 370

#define MAX_CHILDREN_NUMBER 10
typedef struct Node {

	int lineNumber;	
	char* lexeme;
	Node_type type;
	void* attribute;
	int numberOfChildren;
	struct Node** children;	
} Node;


Node* create_node(int nl, Node_type t, char* lexema, 
                  void* att, int nbc, Node** children);

Node* create_leaf(int nl, Node_type t, char* lexema, void* att);

int nb_of_children(Node* n);

Node* child(Node* n, int i);

int pack_nodes(Node*** array_of_nodes, int cur_size, Node* n);

int deep_free_node(Node* n);

int height(Node *n);

int is_leaf(Node* n);

void uncompile(FILE* outputFile, Node* n);

void print_tree(Node *n);




